/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.txweb.interceptor;

import com.jspx.boot.environment.Environment;
import com.jspx.boot.sign.UserType;
import com.jspx.boot.sign.YesNoType;
import com.jspx.sioc.annotation.Ref;
import com.jspx.txweb.Interceptor;
import com.jspx.txweb.ActionInvocation;
import com.jspx.txweb.annotation.Safety;
import com.jspx.txweb.bundle.Bundle;
import com.jspx.txweb.table.Role;

/**
 * Created by IntelliJ IDEA.
 * User:chenYuan (mail:39793751@qq.com)
 * Date: 2006-12-26
 * Time: 18:17:52
 */
public abstract class InterceptorSupport implements Interceptor
{
    /*
不能使用  actionProxy 中的配置，应为如果是夸命名空间的调用，配置会是更底层的一个命名空间
 */
    protected Bundle language;
    @Safety(request = false)
    @Ref(name = Environment.language, test = true)
    public void setLanguage(Bundle language) {
        this.language = language;
    }

    /*
    不能使用  actionProxy 中的配置，应为如果是夸命名空间的调用，配置会是更底层的一个命名空间
     */
    protected Bundle config;
    @Safety(request = false)
    @Ref(name = Environment.config, test = true)
    public void setConfig(Bundle config) {
        this.config = config;
    }


    protected Role createDebugRole()
    {
        Role role = new Role();
        role.setId(Environment.DEBUG_ROLE_ID);
        role.setName(Environment.DEBUG_ROLE_NAME);
        role.setDescription("要关闭调试模式将配置 jspx.properties 里边permission=true,将开启所有权限");
        role.setOfficeType(YesNoType.YES);
        role.setUserType(UserType.ADMINISTRATOR);
        role.setUseUpload(YesNoType.YES);
        role.setUploadSize(2048000); //kb
        role.setUploadImageSize(10240);
        role.setUploadVideoSize(2048000);
        role.setUploadFileTypes("*");
        role.setPutUid(Environment.SYSTEM_ID);
        role.setPutName(Environment.SYSTEM_NAME);
        return role;
    }

    public abstract String intercept(ActionInvocation actionInvocation) throws Exception;
}